﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;
using AuctionHelper.Entity;

namespace AuctionHelper.Repository
{
    /// <summary>
    /// 泛型仓储
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class Repository<T> where T : Table
    {
        /// <summary>
        /// 数据库
        /// </summary>
        protected static Database Database { get; set; }

        /// <summary>
        /// 静态构造函数
        /// </summary>
        static Repository()
        {
            Database = new Database();
            Database.Tables = DataProvider.GetData();
        }

        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="t"></param>
        public static void Add(T t)
        {
            Database.Tables.Add(t);
        }

        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="t"></param>
        public static void Update(T t)
        {
            Database.Tables.Remove(x => x.ID == t.ID);
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="t"></param>
        public static void Delete(T t)
        {

        }

        /// <summary>
        /// 获取所有
        /// </summary>
        /// <returns></returns>
        public static List<T> All()
        {
            return null;
        }

        /// <summary>
        /// 根据表达式获取列表
        /// </summary>
        /// <param name="expression"></param>
        /// <returns></returns>
        public static List<T> Where(Expression expression)
        {
            return null;
        }

        /// <summary>
        /// 根据表达式获取单条
        /// </summary>
        /// <param name="expression"></param>
        /// <returns></returns>
        public static T Single(Expression expression)
        {
            return null;
        }
    }
}
